﻿//-----------------------------------------------------------------
//
// @(#)$Id: FeedbackDetail.aspx.cs,v 1.0 2013/12/13 17:18:49 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 17:18:49 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using ebay.Dal.CenterDB_EbayTableAdapters;
using ebay.Dal.CenterDB_OrderTableAdapters;

public partial class UI_Bas_FeedbackDetail : System.Web.UI.Page
{
    static string act = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DDLBing();
            act = Request.QueryString["act"];
            if (!string.IsNullOrEmpty(act))
            {
                switch (act)
                {
                    case "view":
                        string feedbackid = Request.QueryString["id"];
                        string ebayuserid = Request.QueryString["id2"];
                        T_EbayFeedBackTableAdapter ebayAdapter = new T_EbayFeedBackTableAdapter();

                        DataTable table = ebayAdapter.GetDataByFeedBackID(ebayuserid, feedbackid);
                        if (table.Rows.Count > 0)
                        {
                            DataRow r = table.Rows[0];
                            foreach (Control txtControl in this.form1.Controls)
                            {
                                if (txtControl is HtmlInputText)
                                {
                                    HtmlInputText txtBox = (HtmlInputText)txtControl;
                                    string colName = txtBox.ID.Substring(3, txtBox.ID.Length - 3);
                                    string val = r[colName].ToString();
                                    if (table.Columns[colName].DataType.Name == "DateTime")
                                    {
                                        DateTime valDate = Convert.ToDateTime(DateTime.Parse(val).ToString("yyyy-MM-dd"));
                                        DateTime defaultDateTime = new DateTime(1900, 1, 1);
                                        if (valDate == defaultDateTime)
                                        {
                                            val = "";
                                        }
                                    }
                                    txtBox.Value = val;
                                }
                                else if (txtControl is HtmlSelect)
                                {
                                    HtmlSelect ddList = (HtmlSelect)txtControl;
                                    string colName = ddList.ID.Substring(3, ddList.ID.Length - 3);
                                    ddList.Value = r[colName].ToString();

                                }
                                else if (txtControl is HtmlTextArea)
                                {
                                    HtmlTextArea ddList = (HtmlTextArea)txtControl;
                                    string colName = ddList.ID.Substring(3, ddList.ID.Length - 3);
                                    ddList.Value = r[colName].ToString();

                                }
                            }
                        }
                        break;
                }
            }
        }
    }

    void DDLBing()
    {
        //string[] commenttypes = Enum.GetNames(typeof(eBay .Service .Core .Soap.CommentTypeCodeType));
        //foreach (string comment in commenttypes)
        //{
        //    if (comment != "CustomCode")
        //    {
        //        ddlCommentType.Items.Add(comment);
        //    }
        //}
       T_EbayFeedBackTypeTableAdapter feedBackAdapter = new T_EbayFeedBackTypeTableAdapter();
       ddlCommentType.DataSource = feedBackAdapter.GetData();
       ddlCommentType.DataTextField = "CommentType";
       ddlCommentType.DataBind();
       ddlCommentType.SelectedIndex = 0;

       string[] roletype = Enum.GetNames(typeof (eBay .Service .Core .Soap.TradingRoleCodeType));
       foreach (string r in roletype)
       {
           if (r != "CustomCode")
           {
               ddlRole.Items.Add(r);
           }
       }
       ddlRole.SelectedIndex = 0;
    }   
   
}
